﻿var mongoose = require('mongoose');

mongoose.connect("mongodb://localhost:27017/mern-starter");

var Mark = require('./mark_model.js').grade;
var Student = require('../mongo_student.js').students;
//initialize

Mark.find(function(err, msgs){
	if(msgs.length) return;
	new Mark({
		teacherNo: "2018211222",
  		teacher: "吴镇宇",
  		exam_id: "001",
  		grades: "2014211111:90/2014211113:57"
	}).save();

	new Mark({
		teacherNo: "2018211222",
  		teacher: "吴镇宇",
  		exam_id: "001",
  		grades: "2014211115:88/2014211117:44"
	}).save();
	
	new Mark({
		teacherNo: "2018211222",
  		teacher: "吴镇宇",
  		exam_id: "002",
  		grades: "2014211115:80/2014211117:70"
	}).save();
	
	new Mark({
		teacherNo: "2018211222",
  		teacher: "吴镇宇",
  		exam_id: "003",
  		grades: "2014211111:60/2014211113:50"
	}).save();
	
	new Mark({
		teacherNo: "2018211222",
  		teacher: "吴镇宇",
  		exam_id: "003",
  		grades: "2014211115:40/2014211117:30"
	}).save();
	console.log("jinqule！");
});

Student.find(function(err, msgs){
	if(msgs.length) return;
	new Student({
		studentNo: "2014211111", //id
  		classNo: "2014215222",
  		name: "李",
  		userInfo: "info1",
  		sex: "male",
  		school: "BUPT"
	}).save();
	
	new Student({
		studentNo: "2014211113", //id
  		classNo: "2014215222",
  		name: "张三三",
  		userInfo: "info1",
  		sex: "male",
  		school: "BUPT"
	}).save();

	new Student({
		studentNo: "2014211115", //id
  		classNo: "2014215229",
  		name: "李四四",
  		userInfo: "info2",
  		sex: "female",
  		school: "BUPT"
	}).save();
	
	new Student({
		studentNo: "2014211117", //id
  		classNo: "2014215233",
  		name: "李五六",
  		userInfo: "info2",
  		sex: "female",
  		school: "BUPT"
	}).save();
	console.log("jinqule！");
});

console.log("完成！");